import dolfinx # noqa: F401
import gmsh
import mpi4py.MPI
import viskex
import common_03_dolfinx as common # isort: skip
order = 1
Create a mesh of the unit ball with the provided order.
gmsh.initialize()
gmsh.option.setNumber("General.Verbosity", 1)
mesh, cell_tags, facet_tags, edge_tags, vertex_tags = common.create_unit_ball(
mpi4py.MPI.COMM_WORLD, order=order, num_segments=3)
gmsh.finalize()
Plot the mesh. Note that high order meshes appear more "curved" on the boundary of the circle.
viskex.dolfinx.plot_mesh(mesh)
Plot mesh faces and edges, highlighting their nodes. Note that high order meshes have additional nodes located on faces and edges.
viskex.dolfinx.plot_mesh(mesh, dim=2, show_vertices=True)
viskex.dolfinx.plot_mesh(mesh, dim=1, show_vertices=True)
Plot mesh nodes. Note that high order meshes have more nodes than a first order one, as discussed above.
viskex.dolfinx.plot_mesh(mesh, dim=0)
Plot the cell tags, identifying eight subdomains.
viskex.dolfinx.plot_mesh_tags(mesh, cell_tags, "Cell tags")
Plot the facet tags, identifying eight boundaries and twelve interfaces.
boundaries_range = (19, 26)
interfaces_range = (7, 18)
viskex.dolfinx.plot_mesh_tags(mesh, facet_tags, "Facet tags (all)")
viskex.dolfinx.plot_mesh_tags(
mesh, facet_tags, "Facet tags (boundaries)", lambda grid: grid.threshold(boundaries_range))
viskex.dolfinx.plot_mesh_tags(
mesh, facet_tags, "Facet tags (interfaces)", lambda grid: grid.threshold(interfaces_range))
Plot the edge tags
axes_range = (1, 6)
if edge_tags is not None: # dolfinx < 0.10.0 does not read edge tags
viskex.dolfinx.plot_mesh_tags(mesh, edge_tags, "Edge tags (all)")
if edge_tags is not None: # dolfinx < 0.10.0 does not read edge tags
viskex.dolfinx.plot_mesh_tags(
mesh, edge_tags, "Edge tags (interfaces)", lambda grid: grid.threshold(interfaces_range))
if edge_tags is not None: # dolfinx < 0.10.0 does not read edge tags
viskex.dolfinx.plot_mesh_tags(
mesh, edge_tags, "Edge tags (axes)", lambda grid: grid.threshold(axes_range))
Plot the vertex tags, identifying all vertices on the axes and the origin. Note that in high order meshes the high order nodes are not tagged.
if vertex_tags is not None: # dolfinx < 0.10.0 does not read vertex tags
viskex.dolfinx.plot_mesh_tags(mesh, vertex_tags, "Vertex tags")